package xyz.xtt.exchange.constants;

import java.util.Arrays;
import java.util.Objects;

/**
 * @author huqibo
 *
 */
public enum PayUnitEnum {
	TONG_BAO(0, "通宝支付"), TZ(1, "通钻"), CASH(2, "现金支付");

	private int code;
	private String desc;

	// 构造函数
	private PayUnitEnum(int code, String desc) {
		this.code = code;
		this.desc = desc;
	}

	public int code() {
		return code;
	}

	// 获取描述
	public String desc() {
		return desc;
	}

	public static PayUnitEnum convert(String checkType) {
		return Arrays.asList(PayUnitEnum.values()).stream().filter(x -> Objects.equals(x.name(), checkType)).findFirst()
				.orElse(null);
	}

	public static PayUnitEnum queryConvert(int checkType) {
		return Arrays.asList(PayUnitEnum.values()).stream().filter(x -> Objects.equals(x.code(), checkType)).findFirst()
				.orElse(null);
	}
}
